package com.shopreg.test;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Session;
import org.hibernate.Transaction;

import sun.security.action.GetBooleanAction;

import com.hibernate.sessionfactory.HibernateSessionFactory;
import com.shopreg.entity.Address;
import com.shopreg.entity.PhoneNumbers;
import com.shopreg.entity.PriceDetails;
import com.shopreg.entity.ShopDetails;
import com.shopreg.entity.ShopMenuCategory;
import com.shopreg.entity.ShopMenuItems;

public class ShopRegMain {

	public static void main(String[]args){
		
		Session session = HibernateSessionFactory.getSessionFactory().openSession();
		/*Transaction transaction = session.beginTransaction();
		
		ShopDetails shopDetails = new ShopDetails();
		Address addr = new Address();
		PhoneNumbers phNo = new PhoneNumbers();
		
		addr.setAddrLine1("Test");
		addr.setAddrLine2("Test");
		addr.setAddrLine3("Test");
		addr.setAddrLine4("Test");
		
		phNo.setLandLine1("Test");
		phNo.setLandLine2("Test");
		phNo.setLandLine3("Test");
		phNo.setLandLine4("Test");
		phNo.setMobNumber("Test");
		
		shopDetails.setCountry("India");
		shopDetails.setDistrict("TVM");
		shopDetails.setEntryDate(new Date());
		shopDetails.setPinCode("695015");
		shopDetails.setShopLandMark("opp of Marthoma Church");
		shopDetails.setShopLocation("Paruthippara");
		shopDetails.setShopName("Sandu Resturant10");
		shopDetails.setShopType("3 Star");
		shopDetails.setState("Kerala");
		
		
		shopDetails.setShopAddress(addr);
		addr.setShopDetails(shopDetails);
		shopDetails.setPhoneNumbers(phNo);
		phNo.setShopDetails(shopDetails);
		
		ShopMenuCategory menuCatlog1 = new ShopMenuCategory();
		ShopMenuCategory menuCatlog2 = new ShopMenuCategory();
		
		menuCatlog1.setCategoryDescription("Tasty Food");
		menuCatlog1.setCategoryName("Soups");
		menuCatlog1.setCategoryType("Non Veg");
		menuCatlog1.setShopDetails(shopDetails);
		
		menuCatlog2.setCategoryDescription("Tasty Food");
		menuCatlog2.setCategoryName("Soups");
		menuCatlog2.setCategoryType("Non Veg");
		menuCatlog2.setShopDetails(shopDetails);
		
		shopDetails.setMenuCatlog(new HashSet<ShopMenuCategory>());
		shopDetails.getMenuCatlog().add(menuCatlog1);
		shopDetails.getMenuCatlog().add(menuCatlog2);
		
		ShopMenuItems menuItem1 = new ShopMenuItems();
		ShopMenuItems menuItem2 = new ShopMenuItems();
		
		menuItem1.setItemDescription("Test Desc");
		menuItem1.setItemName("Test Name");
		menuItem1.setItemType("VEG");
		menuItem1.setshopMenuCategory(menuCatlog1);
		
		menuItem2.setItemDescription("Test Desc");
		menuItem2.setItemName("Test Name");
		menuItem2.setItemType("VEG");
		menuItem2.setshopMenuCategory(menuCatlog1);
		
		menuCatlog1.setshopMenuItems(new HashSet<ShopMenuItems>());
		menuCatlog1.getshopMenuItems().add(menuItem1);
		menuCatlog1.getshopMenuItems().add(menuItem2);
		
		PriceDetails priceDet1 = new PriceDetails();
		PriceDetails priceDet2 = new PriceDetails();
		
		priceDet1.setPrice("180.00");
		priceDet1.setUnitQuantity("1P");
		
		
		priceDet2.setPrice("188.00");
		priceDet2.setUnitQuantity("2P");
		
		priceDet1.setShopMenuItems(menuItem1);
		priceDet2.setShopMenuItems(menuItem2);
		
		menuItem1.setPrice(priceDet1);
		menuItem2.setPrice(priceDet2);
		
		session.save(shopDetails);
		transaction.commit();*/
		
		List<ShopMenuCategory> catlogItems = session.createQuery("from ShopMenuCategory").list();
		for(ShopMenuCategory menuCat:catlogItems){
			System.out.println(menuCat.getCategoryId());
			System.out.println(menuCat.getCategoryDescription());
			System.out.println(menuCat.getCategoryName());
			System.out.println(menuCat.getCategoryType());
			
			
			
			
		}
		
	
		
		

	}
}
